var common = require('../../../../utils/common.js');
var app = getApp();


Page({
	data:{
		__PUBLIC__:app.__PUBLIC__
	},
    onLoad:function(options){
    	this.setData({'id':options.id})
    },
    unLock:function(event){
    	var id = this.data.id;
		wx.showModal({
	        title: '确认要开锁吗?',
	        cancelText: "取消",
	        confirmText: "确定",
	        success: function (res) {
	            if (res.confirm) {
	                common.bestCurl('GET','/operate/unlock',res=>{
			    		if(res.data.result == 0){
			    			wx.showToast({
			                    title: '指令发送成功!',
			                    icon: '',
			                    duration: 1000
			                });
			    		}else{
			    			wx.showToast({
			                    title: res.data.msg,
			                    icon: 'none',
			                    duration: 1000
			                });
			    		}
			    	},{'id':id})
	            }else{
	                console.log('用户点击辅助操作')
	            }
	        }
		});	
    },
    Lock:function(){
    	var id = this.data.id;
    	wx.showModal({
            title: '确认要落锁吗?',
            cancelText: "取消",
            confirmText: "确定",
            success: function (res) {
                if (res.confirm) {
                    common.bestCurl('GET','/operate/lock',res=>{
			    		if(res.data.result == 0){
			    			wx.showToast({
			                    title: '指令发送成功!',
			                    icon: '',
			                    duration: 1000
			                });
			    		}else{
			    			wx.showToast({
			                    title: res.data.msg,
			                    icon: 'none',
			                    duration: 1000
			                });
			    		}
			    	},{'id':id})
                }else{
                    console.log('用户点击辅助操作')
                }
            }
        });	
    },
    Ignite:function(){
    	var id = this.data.id;
    	wx.showModal({
            title: '确认要点火吗?',
            cancelText: "取消",
            confirmText: "确定",
            success: function (res) {
                if (res.confirm) {
                    common.bestCurl('GET','/operate/ignite',res=>{
			    		if(res.data.result == 0){
			    			wx.showToast({
			                    title: '指令发送成功!',
			                    icon: '',
			                    duration: 1000
			                });
			    		}else{
			    			wx.showToast({
			                    title: res.data.msg,
			                    icon: 'none',
			                    duration: 1000
			                });
			    		}
			    	},{'id':id})
                }else{
                    console.log('用户点击辅助操作')
                }
            }
        });
    },
    unIgnite:function(){
    	var id = this.data.id;
    	wx.showModal({
            title: '确认要熄火吗?',
            cancelText: "取消",
            confirmText: "确定",
            success: function (res) {
                if (res.confirm) {
                    common.bestCurl('GET','/operate/unignite',res=>{
			    		if(res.data.result == 0){
			    			wx.showToast({
			                    title: '指令发送成功!',
			                    icon: '',
			                    duration: 1000
			                });
			    		}else{
			    			wx.showToast({
			                    title: res.data.msg,
			                    icon: 'none',
			                    duration: 1000
			                });
			    		}
			    	},{'id':id})
                }else{
                    console.log('用户点击辅助操作')
                }
            }
        });
    },
    Whiste:function(){
    	var id = this.data.id;
    	wx.showModal({
            title: '确认要鸣笛吗?',
            cancelText: "取消",
            confirmText: "确定",
            success: function (res) {
                if (res.confirm) {
                    common.bestCurl('GET','/operate/whistle',res=>{
			    		if(res.data.result == 0){
			    			wx.showToast({
			                    title: '指令发送成功!',
			                    icon: '',
			                    duration: 1000
			                });
			    		}else{
			    			wx.showToast({
			                    title: res.data.msg,
			                    icon: 'none',
			                    duration: 1000
			                });
			    		}
			    	},{'id':id})
                }else{
                    console.log('用户点击辅助操作')
                }
            }
        });
    } 
})